package cn.lili.modules.payment.client;

import cn.lili.modules.constant.ServiceConstant;
import cn.lili.modules.payment.entity.dto.UserPointUpdateDTO;
import cn.lili.modules.payment.fallback.WalletPointFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 积分钱包客户端
 *
 * @author liushuai(liushuai711 @ gmail.com)
 * @version v4.0
 * @since 2022/10/20 16:58
 */

@FeignClient(path = "${server.servlet.context-path}", name = ServiceConstant.PAYMENT_SERVICE, contextId = "wallet-point", fallback = WalletPointFallback.class)
public interface WalletPointClient {

    /**
     * 根据用户ID获取用户积分
     *
     * @param userId 用户id
     * @return 积分
     */
    @GetMapping("/feign/point/{userId}")
    Double getUserPoint(@PathVariable String userId);

    /**
     * 用户积分变动
     *
     * @param userPointUpdateDTO 用户积分变动参数
     * @return 操作结果
     */
    @PutMapping("/feign/user/updateMemberPoint")
    void updateMemberPoint(@RequestBody UserPointUpdateDTO userPointUpdateDTO);

}
